home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 128 9
/
q09.d81
/
t.ss player
< prev
next >
Wrap
Text File
|
2022-08-28
|
5KB
|
109 lines
ZERO PAGE: USING SONGSMITH SONGS IN YOUR BASIC PROGRAMS
by Fender Tucker and Jon Mattson
Let's face it, the standard music format for the C-64 and C-128
computers is Craig Chamberlain's SID format from Compute!'s Gazette. It's
been around for years and his editor's capabilities are amazing. There are
only two things that detract from SID format's dominance of the music field
and they are:
(1) The editor takes quite a while to master, and
(2) LOADSTAR's SONGSMITH.
SONGSMITH, by Joe Garrett, is a songmaking program published by
Softdisk that makes transcribing music from sheet music very easy. It also
appeals to the traditional musician because it uses standard musical
notation rather than a computer-oriented format, as SID does. We've been
pushing SONGSMITH for several years, and thanks to Jon Mattson, we now have
a simple, elegant way for SONGSMITH songs to be used in the C-128 mode.
The magic is in the file "128 player.o" which will be found on all
LOADSTAR 128 disks from now on. All you have to do is BLOAD the player and
two music files and wonderful melodies are but a SYS away. Why don't I list
the few lines of BASIC code that will accomplish everything and explain each
one?
100 bload"128 player.o",b0,p6050 :rem load player
110 bload"m.music",b0,p30720 :rem load music data
120 bload"w.music" :rem load instrument data
130 sys6050,0,0,120 :rem play music
140 getkeya$ :rem get s, r or b
150 ifa$="s"thensys6053:goto140 :rem stop music
160 ifa$="r"thensys6056:goto140 :rem resume music
170 ifa$="b"then130 :rem begin music from start
You must load the player code before you do anything else. Just stick
line 100 near the beginning of your program.
SONGSMITH creates five different files for each song. The files you
need to copy onto your program disk are the ones that start with "m." and
"w.". The other three are for SONGSMITH's use only. The "m." file can be
placed anywhere in memory that's safe. Where's "safe"? That depends on
what the rest of your program does. When you use ML routines, it's
important to know where they reside in memory and what other parts of memory
they affect. LOADSTAR 128's menu program puts the music data at 30720 (or
120*256). The "w." file is always saved by SONGSMITH at the same address
and must be loaded into that same address. Just use the syntax in line 120
and it'll be put in the right place.
Now everything's in memory and all you need to do is tell the program
whether you want to start a song, stop a song, or resume a song where it was
stopped. Line 130 starts a song. The syntax is:
SYS6050,bank (0 or 1),low byte, high byte
30720 is equal to 120*256 with 0 left over. This means that 120 is the high
byte and 0 is the low byte. If we had used 40000 in line 110 rather than
30720, we would have 156 as the high byte and 64 as the low byte, since
40000 is equal to 156*256 with 64 left over. You can see that the commands
in lines 110 and 130 are dependent upon each other.
Presumably your program will have user input and line 140 simulates
that. If the user presses "s", then line 150 will stop the music. If he
presses "r" the music will resume from where it was stopped. If he presses
"b" the music will start from the beginning by recalling the initial play
command.
So, in a nutshell,
sys6050,b,l,h starts music
sys6053 stops music
sys6056 resumes music
What could be simpler?
What if you wanted to have the music stop at a certain point, say, at
the end of the first verse? Easy. The current measure is found in memory
location 6059. Use a line like this to stop a song at measure 17.
180 ifpeek(6059)=17thensys6053
How do you know that the first verse ends at measure 17? Write a little
program such as the one above and change this line.
140 geta$:?[home]"peek(6059):ifa$=""then140
As the song plays the measure it's on will be displayed in the upper left
corner of the screen. Just remember the number that's displayed when the
first verse ends.
Memory location 6059 will contain a 255 when the song is over, even if
there are fewer measures in the song. SONGSMITH doesn't allow over 255
measures per song.
The only snags in using "128 player.o" in your programs will be due to
memory or interrupt conflicts. If it doesn't work, try loading the music
somewhere else. If you're using another interrupt-driven routine in your
program, good luck and happy troubleshooting. Jon uses a lot of routines in
the new LOADSTAR 128 presenter and gets them all to work simultaneously.
That's why I asked him to create the new system -- I knew he could do it.
FT
**** End of Text ****